<?php

namespace DEV\SISBundle\Form;
use DEV\SISBundle\Repository\RubrosRepository;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class ArticulosType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        
        $builder
            ->add('codigo')
            ->add('descripcion',null,array('required'=>true))
            ->add('stockMin')
            ->add('piva',null,array('label'=>'IVA %: ','required'=>false))
            ->add('ganancia',null,array('label'=>'Ganacia %: ','required'=>false))
            ->add('rubros',null,array('label'=>'Rubro: ','empty_value'=>false,
                    'query_builder' => function(RubrosRepository $er)
                    { return $er->createQueryBuilder('r')
                                ->orderBy('r.nombre','ASC');}))
        ;
    }

    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'DEV\SISBundle\Entity\Articulos'
        ));
    }

    public function getName()
    {
        return 'dev_sisbundle_articulostype';
    }
}
